import random

def main():
	coin = 5000
	print("现在的金币:", coin)

	while True:
		if not guess():
			if coin <= 500:
				print("金币不足")
				break
			coin -= 500
		else:
			cont = input("是否继续游戏？(y/n): ")
			if cont.lower() == 'n':
				break
			coin += 3000
		print("现在的金币:", coin)
		
	print("游戏结束")


def guess():
	random_number = random.randint(1, 100)
	# print("随机数字:", random_number)

	user_guess = int(input("请输入你猜测的数字（1-100）："))

	if user_guess < random_number:
		print("小了")
	elif user_guess > random_number:
		print("大了")
	else:
		print("恭喜猜中,本轮幸运数字:", random_number)
		return True
	return False

main()	